import Vue from 'vue';
// 上传文件
export function uploadFile(url, formData, name = 'file') {
	return new Promise((resolve, reject) => {
		let a = uni.uploadFile({
			url: Vue.prototype.$imgUrl + 'api.php/common/upload', // 仅为示例，非真实的接口地址
			filePath: url,
			name,
			formData,
			header: {
				'token': uni.getStorageSync('userToken')
			},
			success: (res) => {
				resolve(res.data)
			},
			complete: (com) => {
				let coms = JSON.parse(com.data);
				if (coms.code != 1) {
					
					 uni.showToast({
					 	title: coms.msg,
					 	icon: "none",
					 	duration: 2000,
					 })
					return;
					
				}
			}
		});
	})
}